package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.RCProjectSaleAssignment;
import com.shrct.businessprocess.project.impl.RCProjectImpl;
import com.shrct.businessprocess.project.proxy.RCProjectSaleAssignmentProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPROJECTSALEASSIGNMENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcprojectsaleassignment")
public class RCProjectSaleAssignmentImpl extends BaseModelObject implements RCProjectSaleAssignment {
  public RCProjectSaleAssignmentImpl() {
    super();
  }
  
  public RCProjectSaleAssignmentImpl(final RCProject project) {
    super();
    this.project = project;
  }
  
  @JoinColumn(name = "project_id")
  @ManyToOne(targetEntity = RCProjectImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProject project;
  
  public RCProject getProject() {
    return this.project;
  }
  
  public RCProjectSaleAssignment setProject(final RCProject project) {
    this.project = project;
    return this;			
    
  }
  
  @JoinColumn(name = "employee_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee employee;
  
  public RCEmployee getEmployee() {
    return this.employee;
  }
  
  public RCProjectSaleAssignment setEmployee(final RCEmployee employee) {
    this.employee = employee;
    return this;			
    
  }
  
  private Double rate;
  
  public Double getRate() {
    return this.rate;
  }
  
  public RCProjectSaleAssignment setRate(final Double rate) {
    this.rate = rate;
    return this;			
    
  }
  
  private Double lorRate;
  
  public Double getLorRate() {
    return this.lorRate;
  }
  
  public RCProjectSaleAssignment setLorRate(final Double lorRate) {
    this.lorRate = lorRate;
    return this;			
    
  }
  
  private Boolean isMajor = Boolean.valueOf(false);
  
  public Boolean getIsMajor() {
    return this.isMajor;
  }
  
  public RCProjectSaleAssignment setIsMajor(final Boolean isMajor) {
    this.isMajor = isMajor;
    return this;			
    
  }
  
  public String getEntityName() {
    String _name = this.employee.getName();
    return _name;
  }
  
  public static RCProjectSaleAssignment create(final RCProject project, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCProjectSaleAssignment rCProjectSaleAssignment = new com.shrct.businessprocess.project.impl.RCProjectSaleAssignmentImpl(
    	project
    );
    objectFactory.create(rCProjectSaleAssignment);
    return rCProjectSaleAssignment;			
    
  }
  
  public static RCProjectSaleAssignment createRCProjectSaleAssignmentImpl(final RCProject project, final IObjectFactory objectFactory, final Procedure1<RCProjectSaleAssignment> init) {
    com.shrct.businessprocess.project.RCProjectSaleAssignment rCProjectSaleAssignment = new com.shrct.businessprocess.project.impl.RCProjectSaleAssignmentImpl(
    	project
    );
    objectFactory.create(rCProjectSaleAssignment);
    init.apply(rCProjectSaleAssignment);
    
    return rCProjectSaleAssignment;			
    
  }
  
  public RCProjectSaleAssignmentProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCProjectSaleAssignmentProxy proxy = new com.shrct.businessprocess.project.proxy.RCProjectSaleAssignmentProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
